#include<iostream>
#include<vector>
using namespace std;

// class Solution {
// public:
//     int searchInsert(vector<int>& nums, int target) {
//         for(int i = 0; i < nums.size(); i++){
//             if(nums[i] >= target)return i;
//         }
//         return nums.size();
//     }
// };




class Solution {
public:
    int searchInsert(vector<int>& nums, int target) {
        int low = 0, high = nums.size(), mid;
        while(low < high){
            mid = low + (high - low) / 2;
            if(nums[mid] < target)low = mid + 1;
            else if(nums[mid] > target)high = mid;
            else return mid;
        }
        return low;
    }
};
/**
 * @brief 2022.3.1重写
 * 简单二分
 */